﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Design;

namespace STKMIS
{
    public class DataGridViewMCComboxCell : DataGridViewTextBoxCell
    {
        public override void InitializeEditingControl(int rowIndex, object
             initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                dataGridViewCellStyle);
            DataGridViewMCCombox dgvMCCombox =
                DataGridView.EditingControl as DataGridViewMCCombox;
            try
            {
                dgvMCCombox.PopupGridAutoSize = false;
                //dataWindowControl.RowFilterVisible = true;
                DataGridViewMCComboxColumn dgvMCComboxColumn = (DataGridViewMCComboxColumn)OwningColumn;
                dgvMCCombox.GrvColumnsList = dgvMCComboxColumn.GrvColumnsList;
                dgvMCCombox.IsShowEvent = dgvMCComboxColumn.IsShowEvent;
                dgvMCCombox.KeyWordsColumn = dgvMCComboxColumn.KeyWordsColumn;
                dgvMCCombox.DisplayMemberColumn = dgvMCComboxColumn.DisplayMemberColumn;
                dgvMCCombox.ValueMemberColumn = dgvMCComboxColumn.ValueMemberColumn;
                dgvMCCombox.DataSource = dgvMCComboxColumn.dataSource;

                dgvMCCombox.Text = (string)this.Value;
                dgvMCCombox.RowFilterVisible = true;  //此句必须放在datasource设置后面
            }
            catch (Exception ex)
            {
                 
            }
            
        }

     

        [Browsable(false)]
        public override Type EditType
        {
            get
            {
                return typeof(DataGridViewMCCombox);
            }
        }

        public override Type ValueType
        {
            get
            {
                return typeof(string);
            }
        }
        private DataGridViewMCCombox EditingDataWindow
        {
            get
            {
                DataGridViewMCCombox dataWindowControl =
                    DataGridView.EditingControl as DataGridViewMCCombox;

                return dataWindowControl;
            }
        }
    }
}
